Comparing and Testing Colors
QuickDraw GX provides several functions that allow you to analyze individual color values for various purposes.Checking for Out-of-Gamut Colors
If you have a color value that you want to test against a given color space or color set, you can use theGXCheckColor
function. For example, you can useGXCheckColor
to see if a given color is representable on a particular printer. If the color is not directly representable--that is, if it is out of gamut--you could alert the user to that fact. You could also call theGXConvertColor
function to mimic the automatic color conversion that would take place in printing, to determine what color the printer would use to represent your given color.Both
GXCheckColor
andGXConvertColor
require the color space and color profile of the device the color is destined for. To get the color space and color profile of a printer, you can use theGXGetPrinterViewDevice
andGXGetViewDeviceBitmap
functions.The
GXCheckColor
function is described on page 4-57. TheGXConvertColor
function is described on page 4-60. TheGXGetPrinterViewDevice
function is described in Inside Macintosh: QuickDraw GX Printing. TheGXGetViewDeviceBitmap
function is described in the chapter "View-Related Objects" in this book.Checking Colors for Closeness and Color Space
If you want to compare a user-selected color with the range of colors in a color set,
you can use theGXGetColorDistance
function to determine how far the selected color is from any of the colors in the color set. If the selected color is close enough (in color-space distance) to one of the existing colors in the color set, you could call
theGXConvertColor
function to change the selected color to that closest color. Alternatively, you could callGXGetColorSetParts
andGXSetColorSetParts
to add the selected color to the color set or replace another color in the color set with the selected color.As another example, suppose that you open a document containing shapes of various colors, and you want to save a grayscale version of that document. You might call
GXCheckColor
on each color in the document, and thenGXConvertColor
on each color whose color space is not alreadygxGraySpace
. (You might also save the original color information as a tag object attached to each shape or ink, for later restoration.)The
GXGetColorDistance
function is described on page 4-58. TheGXConvertColor
function is described on page 4-60. TheGXGetColorSetParts
function is described on page 4-75; theGXSetColorSetParts
function is described on page 4-76. TheGXCheckColor
function is described on page 4-57.Predicting Drawing Results
You can preflight, or predict, the results of a drawing operation by using theGXCombineColor
function. You supply a destination color, andGXCombineColor
tells you what would happen if a shape using the ink object you specify were drawn to a destination of that color. This function is as much a test of transfer mode as it is of source and destination colors; you can use it to see how, or even if, drawing occurs under the conditions you specify. For example, if you are using thegxMigrateMode
transfer mode, you may want to adjust the operand so that the result color exactly equals the source color for a particular destination color. You can callGXCombineColor
with different operand values until you get the result you want, and then draw the actual shape. Transfer modes, operands, and source and destination colors are described in the chapter "Ink Objects" in this book.The
GXCombineColor
function is described on page 4-59.